package com.lxl.service.impl;

import com.lxl.dao.IDao;
import com.lxl.dao.impl.UserDaoImpl;
import com.lxl.entity.User;
import com.lxl.mapper.IMapper;
import com.lxl.mapper.impl.UserMapperImpl;
import com.lxl.service.IService;

import java.sql.SQLException;
import java.util.List;

/**
 * @author 北上寻海
 */
public class UserServiceImpl implements IService {
    IDao dao = new UserDaoImpl();
    IMapper mapper = new UserMapperImpl();

    @Override
    public int addUser(User user) throws SQLException {
        int result = -1;
        String userName =user.getUserName();
        String password = user.getPassword();
        if(null!=userName&&null!=password){
            result = dao.addUser(user);
        }
        return  result;
    }

    @Override
    public List findById(Object[] params) throws SQLException {
          return mapper.mapper(dao.findById(params));
    }

    @Override
    public List findAll() throws SQLException {
         return mapper.mapper(dao.findAll());
    }

    @Override
    public int deleteUserById(int id) throws SQLException {
         return dao.deleteUserById(id);
    }

    @Override
    public int updateUserById(Object[] params) throws SQLException {
         return dao.updateUserById(params);
    }

    @Override
    public List verify(String username,String password) throws SQLException {
         return mapper.mapper(dao.verify(username,password));
    }
}
